package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

/**
 * Test for Inventory class.
 */

public class InventoryTest extends TestCase {

	private Inventory i;
	private Recipe r1;
	
	/**
	 * Method to setup fixtures for tests. 
	 */
	public void setUp() {
		i = new Inventory();
		r1 = new Recipe();
		r1.setAmtChocolate(2);
		r1.setAmtCoffee(2);
		r1.setAmtMilk(2);
		r1.setAmtSugar(2);
		r1.setName("Coffee");
		r1.setPrice(2);
	}
	
	/**
	 * Test for setChocolate method.
	 */
	public void testAddChocolate() {
		i.setChocolate(10);
		assertEquals(10,i.getChocolate());
		i.setChocolate(-1);
		assertEquals(0,i.getChocolate());
		
	}
	
	/**
	 * Test for setMilk mwethod.
	 */
	public void testAddMilk() {
		i.setMilk(10);
		assertEquals(10,i.getMilk());
		i.setMilk(-1);
		assertEquals(0,i.getMilk());
	}
	
	/**
	 * Test for setSugar method.
	 */
	public void testAddSugar() {
		i.setSugar(10);
		assertEquals(10,i.getSugar());
		i.setSugar(-1);
		assertEquals(0,i.getSugar());
	}
	
	/**
	 * Test for setCoffee method.
	 */	
	public void testAddCoffee() {
		i.setCoffee(10);
		assertEquals(10,i.getCoffee());
		i.setCoffee(-1);
		assertEquals(0,i.getCoffee());
	}
	
	
	/**
	 * Test for toString method.
	 */
	public void testToString() {
		String inventory = "Coffee: 10\n" +
		"Milk: 10\n" +
		"Sugar: 10\n" +
		"Chocolate: 10\n";
		i.setChocolate(10);
		i.setCoffee(10);
		i.setMilk(10);
		i.setSugar(10);
		assertTrue(inventory.equals(i.toString()));
	}
	
	/**
	 * Test for enoughIngredients method.
	 */
	public void testEnoughIngrediants() {
		i.setChocolate(10);
		i.setCoffee(10);
		i.setMilk(10);
		i.setSugar(10);
		assertTrue(i.enoughIngredients(r1));
		i.setChocolate(1);
		i.setCoffee(1);
		i.setMilk(1);
		i.setSugar(1);
		assertFalse(i.enoughIngredients(r1));
	}
	
	
}
